<template>
    <div class="month-view">
        <div class="weeks">
            <div class="week-title">周日</div>
            <div class="week-title">周一</div>
            <div class="week-title">周二</div>
            <div class="week-title">周三</div>
            <div class="week-title">周四</div>
            <div class="week-title">周五</div>
            <div class="week-title">周六</div>
        </div>
        <div class="days">
            <div class="week" v-for="i in 6">
                <div
                    class="day-cell"
                    :class="{'not-this-month': value.notThisMonth, today: value.today, selected: value == currDay}"
                    @click="dayClick(value)"
                    v-for="(value, key) in month.slice((i-1)*7, (i-1)*7+7)"
                >
                    <div class="cell-title">
                        <h6>{{value.date}}</h6>
                        <span>{{value.cnDate}}</span>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script>

export default {
    components: {  },
    data() {
        return {
        }
    },
    props: {
        month: {
            type: Array,
            required: true
        },
        currDay: {
            type: Object,
            required: true
        }
    },
    methods: {
        dayClick(cell) {
            this.$emit('dayClick', cell);
        }
    }
}
</script>

<style lang="scss" scoped>
@import '../../styles/var.scss';
.month-view {
    display: flex;
    flex-flow: column;
    height: 100%;
    
    .weeks {
        display: flex;
        .week-title {
            padding: 24px 8px;
            flex: 1;
        }
    }
    .days {
        flex: 1;
        display: flex;
        flex-flow: column;
        .week {
            flex: 1;
            display: flex;
            .day-cell {
                flex: 1;
                padding: 8px;
                margin-right: 10px;
                cursor: pointer;
                &.not-this-month {
                    background: #ebebeb;
                }
                &.today h6 {
                    color: #fff;
                    background: #00af5b;
                    border-radius: 50%;
                    text-align: center;
                }
                &.selected:not(.today) {
                    outline: 1px solid #fb0;
                    z-index: 9;
                }
                .cell-title {
                    h6 {
                        font-size: 18px;
                        display: inline-block;
                        vertical-align: middle;
                        width: 30px;
                        height: 30px;
                        line-height: 30px;
                    }
                    span {
                        font-size: 14px;
                        font-weight: normal;
                        color: #999;
                    }
                }
            }
        }
    }
}

</style>